﻿using UnityEngine;
using CommonLib.Pattern.FSM;
using CommonLib.Util;

public class EnemySTPatrol2Chase : EnemyStateTransitionBase
{
	public EnemySTPatrol2Chase(string _key, FSMStateBase _from, FSMStateBase _to, int _priority, RoleCtrl _role) : base(_key, _from, _to, _priority, _role)
	{

	}
	public override bool TransferValid()
	{
		TransitionParam tp = GetTransistionParam(TransitionParamType.Prtrol);
		float vigilance = tp.VigilanceChase;
		if (FindNearestChase(vigilance, out Collider2D col))
		{
			//从追逐中放弃的厌倦对象
			if (col == (FromState as EnemyFSMStatePatrol).TiredTarget)
			{
				Debug.Log("TiredTarget" + col.name);
				return false;
			}
			else
			{
				(ToState as EnemyFSMStateBase).SetTarget(col);
				return true;
			}
		}
		else
			return false;
	}

	public override bool OnCompleteCallBack()
	{
		return base.OnCompleteCallBack();
	}
}
